package Excle.GenerateExcelFile;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @author yangjicong
 * @date 2022/1/19
 *
 * **开始执行**
 */
public class ExcelRun {
	public static void main(String[] args) {

		List<MerchantManageConditionBO> merchantManageConditionBOS = moreBo();
		//调用接口
		String s = listToExcel(merchantManageConditionBOS);
		System.out.println("s = " + s);

	}


	/**
	 * 设置生成excel文件的格式
	 * @param userList
	 * @return
	 */
	public static String listToExcel(List<MerchantManageConditionBO> userList) {
		ExportExcelModel excelModel = new ExportExcelModel();
		excelModel.setSheetName("ACCURATE_BATCH_RECHARGE");
		//这个生成的头是按照对象的顺序来的.
		excelModel.setExcelTitleList(Arrays.asList("外部用户ID", "登录号","商户名称","id","日期"));
		excelModel.setExcelData(userList);
		return ExcelUtil.createExcel(excelModel);
	}

	/**
	 * 设置生成对象字段
	 *
	 * 注意: 生成的顺序是按照类的属性顺序生成的
	 * @return
	 */
	public static List<MerchantManageConditionBO> moreBo(){
		ArrayList<MerchantManageConditionBO> merchantManageConditionBOS = new ArrayList<>();


		MerchantManageConditionBO m1 = new MerchantManageConditionBO();
		m1.setOpenId("11111111111");
		m1.setMobile("222222222222");
		m1.setMerchantName("张三");
		m1.setMerchantId("0");
		m1.setTadyDate(new Date());

		merchantManageConditionBOS.add(m1);

		MerchantManageConditionBO m2 = new MerchantManageConditionBO();
		m2.setOpenId("2222222222");
		m2.setMobile("5555555555555");
		m2.setMerchantName("王五");
		m2.setMerchantId("1");
		m2.setTadyDate(new Date());
		merchantManageConditionBOS.add(m2);

		MerchantManageConditionBO m3 = new MerchantManageConditionBO();
		m3.setOpenId("13123532");
		m3.setMobile("56885856785");
		m3.setMerchantName("李四");
		m3.setMerchantId("2");
		m3.setTadyDate(new Date());
		merchantManageConditionBOS.add(m3);
		return merchantManageConditionBOS;

	}
}
